﻿

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Profile;
using System.Web.Security;
using Gift.Model.ENUM;


    public partial class admin_member_member_add : BaseAdmin
    {
    

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            if (((re.replace(this.memberlogin.Value.ToString()) == "") || (re.replace(this.password.Value.ToString()) == "")) || (re.replace(this.email.Value.ToString()) == ""))
            {
                base.Response.Write("<script language='javascript'>alert('会员名称、邮件地址、登录密码不能为空！');window.location.href='member_add.aspx';</script>");
                base.Response.End();
            }
            string sql = "select * from DB_Member where memberlogin='" + re.replace(this.memberlogin.Value) + "' and isnull(flag,0)!=2 ";
            DataTable table = new DataTable();
            table = SQLAccess.GreatDs(sql).Tables[0];
            if (table.Rows.Count > 0)
            {
                base.Response.Write("<script language='javascript'>alert('对不起，该会员名称已存在，请用别的会员名称！');window.location.href='member_add.aspx';</script>");
                base.Response.End();
            }
            else
            {
                SQLAccess.DoSql(
                "insert into DB_Member (memberlogin,memberpwd,membername,email,updatetime,state,tel1) values ('" + re.replace(this.memberlogin.Value) + "','" + re.EncodeMD5(this.password.Value.Trim()) + "','" + re.replace(this.membername.Value) + "','"
                                             + re.replace(this.email.Value) + "','" + DateTime.Now + "',1,'" + this.tel1.Value.Trim() + "')");
                base.Response.Write("<script language='javascript'>alert('添加成功！');window.location.href='member.aspx';</script>");
                base.Response.End();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.ValidateLoginRule(ERule.AddUser);
            }
        }

    }
